package com.ctu.gzero.compose
{
	import com.ctu.gzero.elements.ParaElement;
	
	import flash.geom.Point;
	
	import mx.collections.ArrayCollection;
	
	public class TxLine
	{
		public var segments:ArrayCollection;
		public var x:Number;
		public var width:Number;
		private var _paraBeginIndex:int;	// paragraph relative offset of first character of the txline
		private var _textLength:int;
		private var _vPos:Number = 0;
		private var _lineSegmentCoord:Array;
		public var feedLineY:Number;
		public var feedLineAscent:Number;
		public var feedLineDescent:Number;
		public var feedLineHeight:Number;
		public var lineHeight:Number; // max lineheight
		public var ascent:Number; // max ascent
		public var descent:Number; // max descent		
		public var _para:ParaElement;
		
		public function TxLine(x:Number,  width:Number, para:ParaElement):void
		{
			this.width = width;
			this.x = x;
			this._para = para;
			segments = new ArrayCollection();
		}
		
		public function isValidCoord(newLineSegmentCoord:Array):Boolean
		{
			var status:Boolean = true;
			var length:int = newLineSegmentCoord.length;
			if(newLineSegmentCoord.length != _lineSegmentCoord.length)
				return false;
			
			for(var i:int=0; i<length; i++)
			{
				var newSegment:Point = newLineSegmentCoord[i] as Point;
				var segment:Point = _lineSegmentCoord[i] as Point;
				if(newSegment.x != segment.x || newSegment.y != segment.y)
				{
					status = false;
					break;
				}
			}
			
			return status;
		}
		
		public function get lineSegmentCoord():Array
		{
			return _lineSegmentCoord;
		}
		
		public function set lineSegmentCoord(val:Array):void
		{
			_lineSegmentCoord = val;
		}
		
		public function get vPos():Number
		{
			return _vPos;
		}
		
		public function set vPos(val:Number):void
		{
			_vPos = val;
		}
		
		public function get paraBeginIndex():int
		{
			return _paraBeginIndex;
		}
		
		public function set paraBeginIndex(val:int):void
		{
			_paraBeginIndex = val;
		}
		
		public function get textLength():int
		{
			return _textLength;
		}
		
		public function set textLength(val:int):void
		{
			_textLength = val;
		}
		
		public function toString():String
		{
			var str:String = "paraBeginIndex:"+_paraBeginIndex+" textLength:"+_textLength;
			
			return str;
		}
		
		public function set para(para:ParaElement):void
		{
			this._para = para; 
		}
		public function get para():ParaElement
		{
			return this._para;	
		}
		
	}
}